package com.zuowei.ycy.user.adapter;

import android.content.Context;
import android.view.View;

import com.and.yzy.frame.adapter.AdapterCallback;
import com.and.yzy.frame.adapter.CommonAdapter;
import com.and.yzy.frame.adapter.ViewHolder;
import com.zuowei.ycy.R;
import com.zuowei.ycy.user.domain.LeftMenuInfo;

import java.util.List;


/**
 * Created by yzy on 2016/ic_01/18.
 */
public class LeftMenuAdapter extends CommonAdapter<LeftMenuInfo> {


    public LeftMenuAdapter(Context context, List<LeftMenuInfo> mDatas, int itemLayoutId, AdapterCallback adapterCallback) {
        super(context, mDatas, itemLayoutId, adapterCallback);

    }

    @Override
    public void convert(final ViewHolder holder, final LeftMenuInfo item, final int positon) {
        holder.setTextViewText(R.id.tv_menu, item.getMenu_name());
        if (item.isSelect()) {
            holder.setBackgroundColor(R.id.rl_menu_bg, mContext.getResources().getColor(R.color.white));

        } else {
            holder.setBackgroundColor(R.id.rl_menu_bg, mContext.getResources().getColor(R.color.app_bg));
        }


        holder.setOnClick(R.id.rl_menu_bg, new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                adapterCallback.adapterInfotoActiity(positon,0);
                item.setIsSelect(true);
                holder.setBackgroundColor(R.id.rl_menu_bg, mContext.getResources().getColor(R.color.white));


                for (int i = 0; i < mDatas.size(); i++) {

                    if (item != mDatas.get(i)) {
                        mDatas.get(i).setIsSelect(false);
                        holder.setBackgroundColor(R.id.rl_menu_bg, mContext.getResources().getColor(R.color.app_bg));
                    }
                }
                notifyDataSetChanged();

            }
        });


    }





}
